﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SerializedData;

namespace KnowledgeBaseManager
{
    public partial class CreateScene : Form
    {
        private SScene mScene;
        private List<SCommand> mCommands = new List<SCommand>();
        private DataCollection mDataCollection = DataCollection.Instance;
        public CreateScene(SScene scene)
        {

            InitializeComponent();
            mScene = scene;

            textBox1.Text = mScene.getName();
            textBox2.Text = mScene.getDescription();
            textBox3.Text = mScene.getTts();
            

            foreach(SCommand command in scene.getCommands()) 
                mCommands.Add(command);



            refreshCommands();
        }

        

        public void refreshCommands()
        {
            
            listViewC.Clear();
            listViewC.BeginUpdate();
            listViewC.Columns.Add("Name", 250);
            listViewC.Columns.Add("Description", 250);

            foreach (SCommand command in mScene.getCommands())
            {
                ListViewItem oneRow = listViewC.Items.Add(command.getName());
                oneRow.SubItems.Add(command.getDescription());
            }
            listViewC.EndUpdate();
        }


        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            mScene.setName(textBox1.Text);
            mScene.setDescription(textBox2.Text);
            mScene.setTts(textBox3.Text);
            
            mDataCollection.modifyOrAddScene(mScene);
            
            ((MainWindow)this.Owner).refreshSceneList();
            this.Close();
        }

        private void groupBox4_Enter(object sender, EventArgs e)
        {

        }

        private void buttonAdd_Click(object sender, EventArgs e)
        {
            AddCommandToScene ac = new AddCommandToScene(mScene);
            ac.Owner = this;
            ac.ShowDialog();

        }
    }
}
